package com.daisuxia.mg.service;

import com.alibaba.fastjson.JSON;
import com.daisuxia.mg.model.UserGridResponse;
import com.daisuxia.mg.utils.HttpUtils;

public class UserGridApi
{

  
  public static UserGridResponse invokeUserGridApi(String access_token, String client_secret, String name, String idCard, String phone)
    throws Exception
  {
    String url = "https://mi.juxinli.com/api/search?client_secret=" + client_secret + "&access_token=" + access_token + "&" + "id_card=" + idCard + "&" + "name=" + name + "&" + "phone=" + phone;
    


    







    String response = HttpUtils.getJsonResponse(url);
    System.err.println(response);
    if ((response.toString().startsWith("{")) && (response.toString().endsWith("}")))
    {
      UserGridResponse userGridResponse = JSON.parseObject(response, UserGridResponse.class);
   
      if ("MIGUAN_SEARCH_SUCCESS".equals(userGridResponse.getCode()))
      {
    	  userGridResponse.setSuccess(true);
    	  return userGridResponse;
      }
      
     
    }
    UserGridResponse userGridResponse = new UserGridResponse();
    userGridResponse.setMessage("调用接口出现异常");
    userGridResponse.setCode("400");
    userGridResponse.setSuccess(false);
    return userGridResponse;
  }
}
